<body>
  <div id="app">
    <input type="text" id="txt">
    <p id="show"></p>
  </div>
</body>
<script type="text/javascript">
	//1
	var obj = {};
	obj.name = 'yangdechao';
	
	//相当于
	Object.defineProperty(obj,'name',{
	    value : 'yangdechao',
	    writable: true,
	    configurable: true,
	    enumerable: true
	})
	
	//2
	Object.defineProperty(obj,'name',{value: 'yangdechao'})
	
	//相当于
	Object.defineProperty(obj,'name',{
	    value: 'yangdechao',
	    writable: false,
	    configurable: false,
	    enumerable: false
	})
  var obj = {}
  Object.defineProperty(obj, 'content', {
    get: function() {
      return obj
    },
    set: function(newValue) {
      document.getElementById('txt').value = newValue
      document.getElementById('show').innerHTML = newValue
    }
  })
  document.addEventListener('keyup', function(e) {
    obj.content = e.target.value
  })
</script>
